$(function () {
    let inputUtil = new Input_util();
    inputUtil.popUpsView();
    let revise = $(".revise");
    let popUpsDown=$(".pop-ups-down");
    popUpsDown.on("click",function () {
        $(".window").css("display","none")
    })
    revise.on("click",function (){
        $(".window").css("display","block")
    });
    $(".view").on("click",function (){
        const requiredPermissions=$(this).attr("permissions")
        console.log(requiredPermissions)
        let menu = new Menu();
        $(".table-body").empty();
        menu.getEmployee(requiredPermissions).then(res =>{
            let menuJson = JSON.parse(res)
            for (const menu of menuJson) {
                console.log(res)
                let row = `<div class="table-row">
                        <div class="table-cell">${menu.name}</div>
                    
                        <div class="table-cell" style="width: 15%">${menu.departments.departmentName}</div>`
                row+=`<div class="table-cell" style="width: 0">
                            <button class="insert">新增</button>`
                if (menu.administrator.permissions !== "all"){
                    row+=`<button class="leave">删除</button>`
                }
                row+=`</div></div>`
                $(".table-body").append(row)
            }
        })
        $(".window").css("display", "block")
    })
    $(".search-img").on("click",function (){
        const val=$(".search-input input").val()
        window.location.href="/www.xiaomi.com/background/home?menuId=105&permissionsMc="+val;
    })
    $(".select").on("click",function (){
        const val=$("#type").val()
        window.location.href="/www.xiaomi.com/background/home?menuId=105&menuDefault="+val;
    })
})